package com.qianyu.project.mapper.provider.zxm;

import com.qianyu.project.entity.SecurityCheckRectification;
import org.apache.ibatis.jdbc.SQL;

public class SecurityCheckProvider {
    public  String getSecurityCheck(SecurityCheckRectification ss){
        return  new SQL(){
            {
                SELECT("*");
                FROM("security_check_rectification scr,project_info pf");
                WHERE("scr.p_id=pf.id");
                if(ss.getId()!=null){
                    WHERE("scr.id like '%"+ss.getId()+"%'");
                }
                if(ss.getSceneCheckSituation()!=null){
                    WHERE("scr.scene_check_situation like '%"+ss.getSceneCheckSituation()+"%'");
                }
                if(ss.getHandleMeasure()!=null){
                    WHERE("scr.handle_measure like '%"+ss.getHandleMeasure()+"%'");
                }
                if(ss.getProjectName()!=null){
                    WHERE("pf.project_name like '%"+ss.getProjectName()+"%'");
                }
                if(ss.getChecker()!=null){
                    WHERE("scr.checker like '%"+ss.getChecker()+"%'");
                }
                if(ss.getUpdateDate()!=null){
                    WHERE("scr.update_date like '%"+ss.getUpdateDate()+"%'");
                }
                if(ss.getApproveStatus()!=null){
                    WHERE("scr.approve_status like '%"+ss.getApproveStatus()+"%'");
                }

            }
        }.toString();
    }

    public  String deleteSecurityCheckId(String id){
        return  new SQL(){
            {
                DELETE_FROM("security_check_rectification");
                WHERE("id='"+id+"'");
            }
        }.toString();
    }
    public  String addsecuritycheck(SecurityCheckRectification ss){
        return  new SQL(){
            {
                INSERT_INTO("security_check_rectification");
                INTO_VALUES("null","#{pId}","#{flowId}","#{checker}","#{buildScale}","#{progress}","#{updateDate}","#{buildPart}","#{basicSituation}","#{sceneCheckSituation}","#{handleMeasure}","#{recheckSituation}","#{recheckSignature}","#{approveStatus}","#{attachIds}");
            }
        }.toString();
    }
    public  String updateSecurityCheck(SecurityCheckRectification ss){
        return  new SQL(){
            {
                UPDATE("security_check_rectification");
                SET("p_id='"+ss.getPId()+"',checker='"+ss.getChecker()+"',build_scale='"+ss.getBuildScale()+"',progress='"+ss.getProgress()+"',update_date='"+ss.getUpdateDate()+"',build_part='"+ss.getBuildPart()+"',basic_situation='"+ss.getBasicSituation()+"',scene_check_situation='"+ss.getSceneCheckSituation()+"',handle_measure='"+ss.getHandleMeasure()+"',recheck_situation='"+ss.getRecheckSituation()+"',recheck_signature='"+ss.getRecheckSignature()+"',approve_status='"+ss.getApproveStatus()+"',attach_ids='"+ss.getAttachIds()+"'");
                WHERE("id='"+ss.getId()+"'");
            }
        }.toString();
    }
}
